<%@page import="java.util.LinkedHashMap"%>
<%@ page import="com.google.gson.Gson, com.google.gson.GsonBuilder"%>
<%
    LinkedHashMap<String, Object> result = (LinkedHashMap<String, Object>) application.getAttribute("result");
    String error = (String) application.getAttribute("error");
%>
<html>

    <head>

        <%-- Start of Stylesheet --%>
        <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="css/bootstrap-fileupload.css">
        <link rel="stylesheet" type="text/css" href="css/jasny-bootstrap-responsive.css">
        <link rel="stylesheet" type="text/css" href="css/jasny-bootstrap.css">
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,400">
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans">
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lobster">
        <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Coda+Caption:800">
        <%-- End of Stylesheet --%>
    </head>

    <body>

        <%-- Start of Header --%>
       <div class="container">
            <div class="header row">
                <div class="span2">
                    <img src="img/bios.png"  class="imageClip">
                </div>
                <div class="span5 offset1">
                    <div class="navbar">
                        <div class="navbar-inner">
                            <div class="nav-collapse collapse">
                                <ul class="nav pull-right">
                                    <li>
                                        <a href="adminMenu.jsp"><i class="icon-home"></i><br />Home</a>
                                    </li>
                                    <li class="current-page">
                                        <a href="fileInput.jsp"><i class="icon-hdd"></i><br />Bootstrap</a>
                                    </li>
                                    <li>
                                        <a href="logInOutController"><i class="icon-remove"></i><br />LogOut</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="hero-status">
            <p>Welcome, Administrator!</p>
        </div>

        <%-- End of Header --%>       
        <h4>File Input</h4>
        <form action="admin/bootstrap" enctype="multipart/form-data" method="POST">
            <input type="file" name="thefile">
            <button type="submit" class="btn">Submit</button>
        </form>
        <br><br>



        <%if (result != null) {%>
        <div class="container">
            <div class="span8 offset2">
                <div class="alert">
                    <strong>RESULT:</strong> <br>
                    <div style="text-align: left;">
                        <pre>
<%
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    gson.toJson(result, out);
    application.removeAttribute("result");
%>
                        </pre>
                    </div>
                </div>
            </div>
        </div>
        <%} else if (error != null) {%>
        <div class="container">
            <div class="span8 offset2">
                <div class="alert alert-error">
                    <strong>FAIL:</strong> <br>
                    <%  
                        if(error.equals("Exception was thrown! String index out of range: -4")){
                            error = "You did not enter any files!";
                        }
                        out.println(error);
                        application.removeAttribute("error");
                    %>
                </div>
            </div>
        </div>
        <%}%>

        <script src="js/script.js"></script>
        <script src="js/fileupload.js"></script>
        <script src="js/jasny-bootstrap.js"></script>

    </body>
</html>
